package com.tinygray;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: tinygray
 * @Description: 公众号:Madison龙少，关注我你会越来越优秀。
 * @className: LockTest
 * @create: 2021-04-14 18:11
 */
public class LockTest {
    public static void main(String[] args) {
        Lock lock = new ReentrantLock();
        try {
            if (lock.tryLock(3, TimeUnit.SECONDS)) {
                lock.lock();
                System.out.println("ss");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }
}
